﻿#region Includes

using System;
using Object=ArtheaEngine.Model.Object;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;

#endregion

namespace ArtheaEngine.Model
{
    public partial class Room : IEntity
    {
        public Room()
        {
        }

        public virtual bool Equals(Room obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            return obj.Id == Id;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Room)) return false;
            return Equals((Room) obj);
        }

        public override int GetHashCode()
        {
            return Id.GetHashCode();
        }

        public virtual string ToString(string format, IFormatProvider formatProvider)
        {
            if (string.IsNullOrEmpty(format)) format = "G";

            switch (format.ToUpper())
            {
                case "G":
                case "N":
                    return Name.ToString(formatProvider);
                case "D":
                    return Description.ToString(formatProvider);
                default:
                    throw new FormatException("invalid room format");
            }
        }

        public void Update()
        {
            foreach (var res in Resets)
            {
                res.Execute();
            }
        }
    }

    public partial class TerrainWrapper
    {
        public Terrain EnumValue
        {
            get { return (Terrain) Value; }
            set { Value = (int) value; }
        }

        public static implicit operator TerrainWrapper(Terrain value)
        {
            return new TerrainWrapper { Value = (int) value };
        }

        public static implicit operator Terrain(TerrainWrapper value)
        {
            if (value == null) return default(Terrain);

            return value.EnumValue;
        }

        public override string ToString()
        {
            return EnumValue.ToString();
        }
    }

    public enum Terrain
    {
        Inside,
        City,
        Field,
        Forest,
        Hills,
        Mountain,
        Water,
        Air,
        Desert,
        Jungle,
        Road,
        Path,
        Cave,
        Swamp
    }
}